Revert "[Python] Optimize BigQuery copy jobs in file loads using multi-source copy"#39106
Conversation
…i-source copy (apache#38983)" This reverts commit 8e4ea73.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request serves as a corrective measure to address stability issues in post-commit tests caused by the recent implementation of BigQuery copy job batching. By reverting the batching logic and refactoring the copy job trigger mechanism, the changes aim to restore the reliability of BigQuery file load operations while maintaining correct write disposition behavior. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the BigQuery file loads pipeline in the Python SDK to trigger copy jobs individually rather than chunking them into batches. It removes the batching logic and simplifies the copy job configuration. The review feedback highlights three important issues: first, grouping temporary tables by tableId instead of their full hashable destination can cause key collisions across different datasets or projects; second, instantiating BigQueryWrapper inline on every element is inefficient and should be replaced with the existing reusable instance; and third, removing the guard check before appending partitions could lead to empty partitions being created.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| finished_temp_tables_load_job_ids_pc | beam.MapTuple( | ||
| lambda destination, job_reference: ( | ||
| bigquery_tools.get_hashable_destination(destination), | ||
| bigquery_tools.parse_table_reference(destination).tableId, | ||
| (destination, job_reference))) | ||
| | beam.GroupByKey() | ||
| | beam.MapTuple(lambda dest, batch: list(batch))) | ||
| | beam.MapTuple(lambda tableId, batch: list(batch))) |
There was a problem hiding this comment.
Using only tableId as the grouping key can cause collisions if the pipeline writes to multiple datasets or projects that contain tables with the same name (e.g., dataset_A.my_table and dataset_B.my_table). Using get_hashable_destination ensures that the full destination (project, dataset, and table) is used as the key, preventing incorrect grouping and potential data corruption.
| finished_temp_tables_load_job_ids_pc | beam.MapTuple( | |
| lambda destination, job_reference: ( | |
| bigquery_tools.get_hashable_destination(destination), | |
| bigquery_tools.parse_table_reference(destination).tableId, | |
| (destination, job_reference))) | |
| | beam.GroupByKey() | |
| | beam.MapTuple(lambda dest, batch: list(batch))) | |
| | beam.MapTuple(lambda tableId, batch: list(batch))) | |
| finished_temp_tables_load_job_ids_pc | beam.MapTuple( | |
| lambda destination, job_reference: ( | |
| bigquery_tools.get_hashable_destination(destination), | |
| (destination, job_reference))) | |
| | beam.GroupByKey() | |
| | beam.MapTuple(lambda dest, batch: list(batch))) |
| try: | ||
| schema = bigquery_tools.table_schema_to_dict( | ||
| self.bq_wrapper.get_table( | ||
| bigquery_tools.BigQueryWrapper().get_table( |
There was a problem hiding this comment.
Instantiating BigQueryWrapper inline on every element/iteration inside process is inefficient because it initializes HTTP clients and credentials repeatedly. It is better to reuse the existing self.bq_wrapper instance.
| bigquery_tools.BigQueryWrapper().get_table( | |
| self.bq_wrapper.get_table( |
| else: | ||
| if latest_partition.files: | ||
| partitions.append(latest_partition.files) | ||
| partitions.append(latest_partition.files) |
There was a problem hiding this comment.
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
|
Waiting for checks |
|
All tests passed. |
…i-source copy" (apache#39106) * Revert "[Python] Optimize BigQuery copy jobs in file loads using multi-source copy (apache#38983)" This reverts commit 8e4ea73. * Trigger postcommit test.
Reverting #38983 since it is causing some postcommit test failure.
See #30513 (comment) for detail.